<?php
namespace Core\CoreCommons;

/**
* Communication listener about provided parameters from javascript and send result to javascript
*
* @method JSON GetDatas()
* @method void SendData($response)
*/
class ComListener 
{
	/**
	 * Get all datas contain in the buffer
	 *
	 * @return JSON This response contains the JSON response provided by client side
	 */
	public static function GetDatas()
	{
		$data = json_decode(file_get_contents("php://input"));
	
		if($data == null)
		{
			throw new \Exception("Data is null");
		}
	
		return $data;
	}

	/**
	 * This is an async method
	 *
	 * @param object $response The data to send 
	 *
	 */
	public static function SendData($response)
	{
		$jsn = json_encode($response);
		print_r($jsn);
	}
}
?> 